package embuzzled.g5;

import java.util.ArrayList;

public class Letters 
{
	static boolean[][] A = {
			{false, true, false},
			{true, true, true},
			{true, false, true}
	};
	
	static boolean[][] B = {
			{true, true, false},
			{true, true, true},
			{true, true, true}
	};
	
	static boolean[][] C = {
			{true, true, true},
			{true, false, false},
			{true, true, true}
	};
	
	static boolean[][] D = {
			{true, true, false},
			{true, false, true},
			{true, true, false}
	};
	
	static boolean[][] E = {
			{true, true, true},
			{true, true, false},
			{true, true, true}
	};
	
	static boolean[][] F = {
			{true, true, true},
			{true, true, false},
			{true, false, false}
	};
	
	static boolean[][] G = {
			{true, true, false},
			{true, false, true},
			{true, true, true}
	};
	
	static boolean[][] H = {
			{true, false, true},
			{true, true, true},
			{true, false, true}
	};
	
	static boolean[][] I = {
			{false, true, false},
			{false, true, false},
			{false, true, false}
	};
	
	static boolean[][] J = {
			{false, false, true},
			{true, false, true},
			{true, true, true}
	};
	
	static boolean[][] K = {
			{true, false, true},
			{true, true, false},
			{true, false, true}
	};
	
	static boolean[][] L = {
			{true, false, false},
			{true, false, false},
			{true, true, true}
	};
	
	static boolean[][] M = {
			{true, true, true},
			{true, true, true},
			{true, false, true}
	};
	
	static boolean[][] N = {
			{true, true, false},
			{true, false, true},
			{true, false, true}
	};
	
	static boolean[][] O = {
			{true, true, true},
			{true, false, true},
			{true, true, true}
	};
	
	static boolean[][] P = {
			{true, true, true},
			{true, true, true},
			{true, false, false}
	};
	
	static boolean[][] Q = {
			{true, true, true},
			{true, false, true},
			{true, true, false}
	};
	
	static boolean[][] R = {
			{true, true, false},
			{true, true, false},
			{true, false, true}
	};
	
	static boolean[][] S = {
			{false, true, true},
			{false, true, false},
			{true, true, false}
	};
	
	static boolean[][] T = {
			{true, true, true},
			{false, true, false},
			{false, true, false}
	};
	
	static boolean[][] U = {
			{true, false, true},
			{true, false, true},
			{true, true, true}
	};
	
	static boolean[][] V = {
			{true, false, true},
			{true, false, true},
			{false, true, false}
	};
	
	static boolean[][] W = {
			{true, false, true},
			{true, true, true},
			{true, true, true}
	};
	
	static boolean[][] X = {
			{true, false, true},
			{false, true, false},
			{true, false, true}
	};
	
	static boolean[][] Y = {
			{true, false, true},
			{true, true, true},
			{false, true, false}
	};
	
	static boolean[][] Z = {
			{true, true, false},
			{false, true, false},
			{false, true, true}
	};
	
	static ArrayList<boolean[][]> letters3x3;
	
	static
	{
		letters3x3 = new ArrayList<boolean[][]>();
		letters3x3.add(A);
		letters3x3.add(B);
		letters3x3.add(C);
		letters3x3.add(D);
		letters3x3.add(E);
		letters3x3.add(F);
		letters3x3.add(G);
		letters3x3.add(H);
		letters3x3.add(I);
		letters3x3.add(J);
		letters3x3.add(K);
		letters3x3.add(L);
		letters3x3.add(M);
		letters3x3.add(N);
		letters3x3.add(O);
		letters3x3.add(P);
		letters3x3.add(Q);
		letters3x3.add(R);
		letters3x3.add(S);
		letters3x3.add(T);
		letters3x3.add(U);
		letters3x3.add(V);
		letters3x3.add(W);
		letters3x3.add(X);
		letters3x3.add(Y);
		letters3x3.add(Z);
	}
	
	/**
	 *  Returns a 2d boolean array representing a 3x3
	 *  image of this character. Trues should be colored in
	 *  Falses should be blank.
	 *  Should work for lower and upper case.
	 *  Undefined behavior for non-letters.
	 *  Returns distinct letters. Altering the return value for letter 'x'
	 *  should not affect other letters of the same type.
	 * @param c A letter.
	 * @return A 2d array of booleans graphically representing this letter.
	 */
	public static boolean[][] getLetter3x3(char c)
	{
		char c2 = Character.toUpperCase(c);
		int i = Character.getNumericValue(c2) - Character.getNumericValue('A');
		
		boolean[][] map;
		
		if(i < 0 || i > letters3x3.size())
			return new boolean[3][3];
		else
			map = letters3x3.get(i);
		
		return Helper.copyArray(map);
	}
	
	/**
	 * Generates an array containing the boolean maps
	 * for each letter in the given string.
	 * As above, undefined behavior for non alphabet characters
	 * such as numbers or spaces.
	 * @param s A string
	 * @return An ArrayList containing a boolean map for each
	 *         letter in the string.
	 */
	public static ArrayList<boolean[][]> getString3x3(String s)
	{
		ArrayList<boolean[][]> string = new ArrayList<boolean[][]>();
		
		for(int i = 0; i < s.length(); i++)
		{
			char c = s.charAt(i);
			string.add(getLetter3x3(c));
		}
		
		return string;
	}
	
	// Based on font by "Kekskiller" at http://tricorne.blogger.de/static/antville/tricorne/images/3x3%20font.png
}
